package com.whfc.ms.api.emp.controller;

import com.whfc.common.result.Result;
import com.whfc.common.result.ResultUtil;
import com.whfc.common.util.SessionAttr;
import com.whfc.emp.param.AppHelmetTestParam;
import com.whfc.emp.param.AppTrainAddParam;
import com.whfc.fuum.entity.SysUser;
import com.whfc.ms.api.emp.service.MsAppHelmetService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

/**
 *筑邦智能安全帽测试工具
 */
@RestController
@RequestMapping("/ms/api/emp/helmet")
public class AppZbznHelmetController {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private MsAppHelmetService msAppHelmetService;

    /**
     * 筑邦智能获取token
     * @param user
     * @return
     */
    @GetMapping("/zbzn/getToken")
    public Result getToken(@SessionAttribute(SessionAttr.MS_USER) SysUser user) throws IOException {
        logger.info("筑邦智能获取token，loginer:{}", user.getUsername());
        String token = msAppHelmetService.getToken();
        return ResultUtil.success(token);
    }


    @RequestMapping("/zbzn/test111")
    public  void test111(@RequestParam(value = "act") String act) {
        logger.info("test111");
        msAppHelmetService.test111(act);
    }

    @PostMapping("/zbzn/setHelmetData")
    public Result setHelmetData(@Validated @RequestBody AppHelmetTestParam request) {
        logger.info("模拟安全帽消息时间，mockData:{}", request.getMockData());
        msAppHelmetService.setHelmetData(request.getMockData());
        String a ="{\"data\":{\"privacy_switch\":\"0\",\"b1\":\"\",\"b2\":\"\",\"boot_broadcast\":\"0\",\"max_temp\":\"0.00\",\"min_shrink\":\"0\",\"gas_volt\":\"0\",\"device_id\":\"866652022701057\",\"acc_list\":\"2\",\"shrink\":\"0\",\"notuploaded_video_count\":\"0\",\"pressure\":\"2\",\"nearvolt\":\"2\",\"diastolic\":\"0\",\"ca_report_time\":\"0\",\"user_id\":\"1134\",\"new_low\":\"0\",\"sos_height\":\"10000.00\",\"f_id\":\"4775\",\"pwd\":\"123456\",\"role\":\"5250\",\"g_id\":\"12\",\"last_count_online_time\":\"1762291912\",\"user_name\":\"毛欲江\",\"c_time\":\"1761545014\",\"real_name\":\"毛欲江\",\"min_o2\":\"19.5\",\"max_diastolic\":\"0\",\"max_o2\":\"23.5\",\"g_name\":\"武汉汇力德-集电线路\",\"electrostatic\":\"1\",\"min_temp\":\"0.00\",\"ca_last_login_time\":\"1762291912\",\"department\":\"5250\",\"max_heartbeat\":\"0\",\"cap_type\":\"3\",\"mobile\":\"13087866137\",\"health\":\"2\",\"min_heartbeat\":\"0\",\"co\":\"10.0\",\"upload_video_num\":\"0\",\"user_img\":\"https://111.120.11.161:10006/public/images/default.jpeg\",\"c_user_id\":\"2\",\"rtmp_open\":\"0\",\"app_last_login_time\":\"0\",\"account_id\":\"2\",\"tk\":\"2\",\"min_blood_oxygen\":\"0\",\"max_blood_oxygen\":\"0\",\"min_wrist_temp\":\"0\",\"max_wrist_temp\":\"0\"},\"y_point\":\"106.392358052787785\",\"cmd\":\"server_push_sos\",\"sos_type\":2,\"time\":1762299939,\"x_point\":\"27.238555713757208\"}\n";
        return ResultUtil.success();
    }
}
